<?php

/**
 * 签署公司仓库
 * @author wangwx 2015-5-22
 */
namespace common\repositories\myhtsq;
use common\repositories\BaseRepository;
use common\entities\myhtsq\ContractCompanyEntity;
class ContractCompanyRepository extends BaseRepository{

	/**
	 * 构造方法
	 * @param unknown $config (optional)
	 */
	public function __construct($config = [])
	{
		parent::__construct($config);
	}
	
	/**
	 * 根据性质id,获取公司列表
	 * @param string $propertyId 性质id
	 * @return array
	 */
	public static function getContractCompanyListByPropertyId($propertyId) {
		return ContractCompanyEntity::find()->where('find_in_set(:propertyId,property_id)')->params([':propertyId'=>$propertyId])->all();
	}
	
	/**
	 * 根据公司guid，获取公司名称
	 * @param string $companyId 公司id
	 * @return string
	 */
	public static function getContractCompanyNameByCompanyId($companyId) {
		$str = ContractCompanyEntity::find()->select('company_name')->where(['company_id'=>$companyId])->scalar();
		if (empty($str)) {
			$str = '';
		}
		return $str;
		
	}


	public static function getContractIdByName($companyname) {
		$str = ContractCompanyEntity::find()->select('company_id')->where(['company_name'=>$companyname])->scalar();
		if (empty($str)) {
			$str = '';
		}
		return $str;

	}
	
}